package cdu.javaendwork.Controller.Admin.User;

import cdu.javaendwork.model.sqlModel.User;
import cdu.javaendwork.service.Impl.User.UserServiceImpl;
import cdu.javaendwork.service.Interface.User.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/user_ban")
public class UserBanController extends HttpServlet{

    UserService userService=new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uid=req.getParameter("userid");
        int userid = Integer.parseInt(uid);

        User user = userService.findById(userid);

        userService.update(userid,user.getUsername(),user.getPassword(),user.getPassword(),
                user.getUserprofile(),user.getPhoto(),3
        );

        req.getRequestDispatcher("user_list").forward(req,resp);

    }
}
